

import numpy as np

# 0-1均匀分布的浮点型随机数组
arr1 = np.random.random(5)
print(arr1) # [0.55903176 0.26395801 0.6933364  0.22484565 0.84719931]

"""
如果想创建 60-100 范围内均匀分布的 3 行 3 列随机数组，可输
入 (100-60)*np.random.random( (3,3) ) + 60
"""
arr2 = (100-60)*np.random.random((3,3)) + 60
print(arr2)
"""
[99.22804947 81.91647948 73.28894025]
 [65.39634818 87.7154773  95.75986902]]
"""

# 整数型随机数组
arr2 = np.random.randint(10,100, (1,15)) # 形状为(1,15)的矩阵
print( arr2 ) # [[65 13 98 39 45 60 82 32 43 80 45 81 47 58 39]]

# 服从正态分布的随机数组
arr3 = np.random.normal( 0,1,(2,3) ) # 形状为(2,3)的二维矩阵
print(arr3)
arr3 = np.random.normal( 0,1,(5) ) # 形状为(2,3)的二维矩阵
print(arr3)